var status = -1;
var beauty = 0;
var hair_Colo_new;
var ct = -1;
var card = 0;

function action(e, d, c) {
    if (e == 0) {
        cm.dispose();
        return
    } else {
        if (e == 1) {
            status++
        } else {
            status--
        }
    }
    switch (status) {
        case 0:
            cm.askMenu("如果您有#b#t5150052##k或者#b#t5151036##k，就让我来为您打造新的形象吧！下面做出您的选择吧。\r\n#b#L0#美发（使用#b#t5150052#）#l\r\n");
            break;
        case 1:
            if (c == 0) {
                var a = cm.getPlayerStat("HAIR");
                hair_Colo_new = [];
                beauty = 1;
                if (cm.getPlayer().getGender() == 0) {
                    hair_Colo_new = [40700, 40710, 40720, 40730, 40740, 40750, 40760, 40770, 40780, 40790, 40680, 36770, 36800, 36810, 36820, 36830, 36840, 36850, 36860, 36880, 36890, 36900, 36910, 36920, 36930, 36940, 36950, 36980, 36990, 40000, 40020, 40030, 40040]
                } else {
                    hair_Colo_new = [44020, 44030, 44040, 44050, 44060, 44070, 44080, 44090, 44100, 44110, 44120, 44130, 44140, 44150, 44160, 44170, 44180, 44190, 44200, 44290, 44300, 44310, 44320, 44330, 44340, 44350, 44360, 44370, 44380, 44390, 44400, 44410, 44420, 44430, 41900, 41910, 41920, 41930, 41940, 41950, 41960, 41970, 41980, 41990, 42010, 42060, 42070, 42090, 42110, 42120, 42090, 42080, 41840, 41830, 41820, 41810, 41770, 41760, 41750, 41740, 41730, 41720, 41700, 41690, 41680, 41670, 41660, 41650, 41640, 41600, 41590, 41580, 41570, 41560, 41550, 41540, 41520, 41510, 41490, 41480, 41470, 41460, 41440, 41430, 41420, 41410, 41400, 41390, 41380, 41370, 41360, 41350, 41340, 41220, 41210, 41200, 41190, 41160, 41150, 41070, 41080, 41060, 41377, 41390, 41440, 41460, 41470, 41420, 41430, 41220, 41340, 41600, 41650, 41660, 41640, 41690, 41680, 41670, 41660, 41720, 41710, 41700, 41490, 41470, 41480, 41520, 41510, 41555, 41560, 41540, 41585, 41593, 41570, 41580, 41576, 41870, 41860, 41880, 41900, 41890, 41916, 41930, 41920, 41950, 41940, 41936, 41980, 41970, 41730, 41740, 41750, 41760, 41770, 41800, 41810, 41820, 41830, 41840, 41850, 44140, 44130, 44150, 44110, 44100, 44120]
                }
                for (var b = 0; b < hair_Colo_new.length; b++) {
                    hair_Colo_new[b] = hair_Colo_new[b] + (a % 10)
                }
                cm.askAvatar("我能把您现在的头发换个全新的发型。您对现在的发型不厌倦吗？只要您有#b#t5150052##k，我就帮您换发型。慢慢挑选您想要的发型吧！", hair_Colo_new, 5150052)
            }
            break;
        case 2:
            if (beauty == 1) {
                if (cm.setAvatar(5150052, hair_Colo_new[c]) == 1) {
                    cm.dispose();
                    cm.playerMessage(1, "好了，让朋友们赞叹您的新发色吧！");
                    card = 1
                } else {
                    if (cm.getPlayer().getCSPoints(1) >= 980) {
                        ct = 1
                    }
                    if (cm.getPlayer().getCSPoints(2) >= 980) {
                        ct = 2
                    }
                    if (ct != -1) {
                        cm.getPlayer().modifyCSPoints(ct, -980);
                        cm.gainItem(5150052, 1)
                    } else {
                        beauty = -1
                    }
                    action(e, d, c)
                }
            }
            break;
        case 3:
            if (card == 0) {
                if (cm.getPlayer().getCSPoints(1) >= 980) {
                    if (cm.setRandomAvatar(hair_Colo_new) == 1) {
                        cm.getPlayer().modifyCSPoints(1, -980);
                        if (beauty == 1) {
                            cm.dispose();
                            cm.playerMessage(1, "好了，让朋友们赞叹您的新发型吧！");
                            card = 1
                        }
                    }
                } else {
                    cm.dispose();
                    cm.playerMessage(1, "你好像没有足够的点卷/抵用卷！");
                    card = 1
                }
            }
            cm.dispose();
            break;
        default:
            cm.dispose();
            break
    }
}

function start() {
    status = -1;
    action(1, 0, 0)
};